package cn.edu.hbwe.book.service;

import java.sql.SQLException;
import cn.edu.hbwe.book.dao.Uesrdao;
import cn.edu.hbwe.book.entity.User;
import cn.edu.hbwe.book.exception.LoginException;

public class UserService {
	public User login(String username, String password) throws LoginException {
		Uesrdao dao = new Uesrdao();
		try {
			//根据登录时表单输入的用户名和密码，查找用户
			User user = dao.findUserByUsernameAndPassword(username, password);
			return user;
		} catch (SQLException e) {
			e.printStackTrace();
			throw new LoginException("用户名和密码错误");
		}
		
	}
}
